﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!-- ContextMenu -->
    <ContextMenu xml:lang="en-US" x:Shared="false" 
                x:Key="FlowViewer_ContextMenu"
                TextBlock.LineHeight="Auto">
        <MenuItem Command="ApplicationCommands.Copy" Header="_Copy" InputGestureText="" />
        <MenuItem Command="ApplicationCommands.SelectAll" Header="Select A_ll" InputGestureText="" />
    </ContextMenu>

    <!-- Brushes -->
    <LinearGradientBrush x:Key="FlowViewer_ZoomButtonUpBrush" StartPoint="0,0" EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStop Offset="0" Color="#9fff"/>
            <GradientStop Offset="1" Color="#6000"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="FlowViewer_ZoomButtonDownBrush" StartPoint="0,0" EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStop Offset="0" Color="#9000"/>
            <GradientStop Offset="1" Color="#6fff"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>

    <!-- Geometries -->
    <PathGeometry x:Key="FlowViewer_UpArrowIcon">
        <PathFigure StartPoint="0,5" IsClosed="True">
            <LineSegment Point="10,5" IsStroked="True" />
            <LineSegment Point="5,0" IsStroked="True" />
        </PathFigure>
    </PathGeometry>

    <PathGeometry x:Key="FlowViewer_DownArrowIcon">
        <PathFigure StartPoint="0,0" IsClosed="True">
            <LineSegment Point="10,0" IsStroked="True" />
            <LineSegment Point="5,5" IsStroked="True" />
        </PathFigure>
    </PathGeometry>

    <!-- Buttons -->
    <Style x:Key="FlowViewer_GrowShrinkOpacityButtonBase" TargetType="{x:Type ButtonBase}" BasedOn="{x:Null}">
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Opacity" Value=".5"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Padding" Value="3,1"/>
        <Setter Property="BorderBrush" Value="{x:Null}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="MinHeight" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Border Background="{TemplateBinding Background}">
                        <ContentPresenter x:Name="Content" RenderTransformOrigin=".5, .5"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="RenderTransform" TargetName="Content">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1.1" ScaleY="1.1"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="RenderTransform" TargetName="Content">
                                <Setter.Value>
                                    <ScaleTransform ScaleX=".9" ScaleY=".9"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value=".3"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Opacity" Value="1"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="FlowViewer_GrowShrinkOpacityRepeatButton" 
         TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource FlowViewer_GrowShrinkOpacityButtonBase}">
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Delay" Value="1000"/>
        <Setter Property="Interval" Value="250"/>
    </Style>

    <Style x:Key="FlowViewer_ZoomInButton"
           TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource FlowViewer_GrowShrinkOpacityRepeatButton}">
        <Setter Property="Padding" Value="0,2,2,2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent"
                            Padding="{Binding Path=Padding, RelativeSource={RelativeSource TemplatedParent}}">
                        <Viewbox x:Name="Content" RenderTransformOrigin=".5,.5">
                            <Canvas Width="32" Height="32">
                                <Path Width="32" Height="32"
                                      Fill="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Path.Data>
                                        <GeometryGroup>
                                            <EllipseGeometry Center="16,16" RadiusX="16" RadiusY="16"/>
                                        </GeometryGroup>
                                    </Path.Data>
                                </Path>
                                <Path Width="32" Height="32" x:Name="Sheen"
                                      Fill="{StaticResource FlowViewer_ZoomButtonUpBrush}">
                                    <Path.Data>
                                        <GeometryGroup>
                                            <EllipseGeometry Center="16,16" RadiusX="16" RadiusY="16"/>
                                        </GeometryGroup>
                                    </Path.Data>
                                </Path>
                                <Path StrokeThickness="5" Canvas.Top="16" Canvas.Left="16"
                                      Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Path.Data>
                                        <GeometryGroup>
                                            <LineGeometry StartPoint="-10,0" EndPoint="10,0"/>
                                            <LineGeometry StartPoint="0,-10" EndPoint="0,10"/>
                                        </GeometryGroup>
                                    </Path.Data>
                                </Path>
                            </Canvas>
                        </Viewbox>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="RenderTransform" TargetName="Content">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1.1" ScaleY="1.1"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="RenderTransform" TargetName="Content">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Fill"
                                    Value="{StaticResource FlowViewer_ZoomButtonDownBrush}" TargetName="Sheen"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FlowViewer_ZoomOutButton"
         TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource FlowViewer_GrowShrinkOpacityRepeatButton}">
        <Setter Property="Padding" Value="2,2,0,2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent"
                  Padding="{Binding Path=Padding, RelativeSource={RelativeSource TemplatedParent}}">
                        <Viewbox x:Name="Content" RenderTransformOrigin=".5,.5">
                            <Canvas Width="32" Height="32">
                                <Path Width="32" Height="32"
                      Fill="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Path.Data>
                                        <GeometryGroup>
                                            <EllipseGeometry Center="16,16" RadiusX="16" RadiusY="16"/>
                                        </GeometryGroup>
                                    </Path.Data>
                                </Path>
                                <Path Width="32" Height="32" x:Name="Sheen"
                      Fill="{StaticResource FlowViewer_ZoomButtonUpBrush}">
                                    <Path.Data>
                                        <GeometryGroup>
                                            <EllipseGeometry Center="16,16" RadiusX="16" RadiusY="16"/>
                                        </GeometryGroup>
                                    </Path.Data>
                                </Path>
                                <Path StrokeThickness="5" Canvas.Top="16" Canvas.Left="16"
                      Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Path.Data>
                                        <LineGeometry StartPoint="-10,0" EndPoint="10,0"/>
                                    </Path.Data>
                                </Path>
                            </Canvas>
                        </Viewbox>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="RenderTransform" TargetName="Content">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1.1" ScaleY="1.1"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="RenderTransform" TargetName="Content">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Fill" 
                                    Value="{StaticResource FlowViewer_ZoomButtonDownBrush}" TargetName="Sheen"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Slider -->
    <Style x:Key="FlowViewer_Slider_RepeatButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <PathGeometry x:Key="FlowViewer_Slider_ThumbGeometry" FillRule="Nonzero">
        <PathFigure StartPoint="1,0" IsClosed="True">
            <LineSegment Point="10,0"/>
            <LineSegment Point="11,1"/>
            <LineSegment Point="11,13"/>
            <LineSegment Point="6.5,17"/>
            <LineSegment Point="4.5,17"/>
            <LineSegment Point="0,13"/>
            <LineSegment Point="0,1"/>
            <LineSegment Point="1,0"/>
        </PathFigure>
    </PathGeometry>

    <Style x:Key="FlowViewer_Slider_Thumb" TargetType="{x:Type Thumb}">
        <Setter Property="Background" Value="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Padding" Value="6"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="Transparent" Margin="-2"
                            Padding="{Binding Path=Padding,RelativeSource={RelativeSource TemplatedParent}}">
                        <Viewbox HorizontalAlignment="Center" VerticalAlignment="Center"
                                 Width="{Binding Path=FontSize, RelativeSource={RelativeSource TemplatedParent}}">
                            <Viewbox.LayoutTransform>
                                <ScaleTransform ScaleX="1" ScaleY="1"/>
                            </Viewbox.LayoutTransform>
                            <Canvas Width="13" Height="17">
                                <Path 
                                      Fill="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}"
                                      Data="{StaticResource FlowViewer_Slider_ThumbGeometry}"/>
                                <Path Stroke="{TemplateBinding Background}" StrokeThickness=".75" StrokeMiterLimit="1"
                                      StrokeLineJoin="Round" StrokeEndLineCap="Round" StrokeDashCap="Round"
                                      Data="{StaticResource FlowViewer_Slider_ThumbGeometry}">
                                    <Path.Fill>
                                        <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                                            <LinearGradientBrush.GradientStops>
                                                <GradientStopCollection>
                                                    <GradientStop Color="#c999" Offset="0.5"/>
                                                    <GradientStop Color="#cfff" Offset="0.8"/>
                                                    <GradientStop Color="#cfff" Offset="0.2"/>
                                                </GradientStopCollection>
                                            </LinearGradientBrush.GradientStops>
                                            <LinearGradientBrush.RelativeTransform>
                                                <TransformGroup>
                                                    <TranslateTransform X="-0.5" Y="-0.5"/>
                                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                                    <SkewTransform AngleX="0" AngleY="0"/>
                                                    <RotateTransform Angle="110"/>
                                                    <TranslateTransform X="0.5" Y="0.5"/>
                                                </TransformGroup>
                                            </LinearGradientBrush.RelativeTransform>
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                            </Canvas>
                        </Viewbox>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FlowViewer_Slider" TargetType="{x:Type Slider}">
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Background" Value="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="#0000"/>
        <Setter Property="Foreground" Value="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="IsSnapToTickEnabled" Value="True"/>
        <Setter Property="RenderTransformOrigin" Value=".5,.5"/>
        <Setter Property="MinWidth" Value="50"/>
        <Setter Property="MinHeight" Value="0"/>
        <Setter Property="Width" Value="Auto"/>
        <Setter Property="Padding" Value="2,0"/>
        <Setter Property="Height" Value="Auto"/>
        <Setter Property="Opacity" Value=".75"/>
        <Setter Property="Delay" Value="1000"/>
        <Setter Property="Interval" Value="250"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Slider}">
                    <Border Background="Transparent" Padding="{TemplateBinding Padding}">
                        <Grid ClipToBounds="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto" MinHeight="{TemplateBinding Slider.MinHeight}"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TickBar x:Name="TopTick" Fill="{TemplateBinding Foreground}"
                                     Grid.Row="0" Placement="Top" Height="4" Visibility="Collapsed"/>
                            <Border Height="2" Grid.Row="1" CornerRadius="2" 
                                    Background="{TemplateBinding Foreground}" Opacity=".5" />
                            <Canvas Grid.Row="1" VerticalAlignment="Center" Height="4">
                                <Rectangle x:Name="PART_SelectionRange" Canvas.Top="1"
                                           Fill="{TemplateBinding Foreground}" Height="2.0" Visibility="Hidden"/>
                            </Canvas>
                            <Track Grid.Row="1" Name="PART_Track">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource FlowViewer_Slider_RepeatButton}"
                                                  Command="Slider.DecreaseLarge"/>
                                </Track.DecreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Style="{StaticResource FlowViewer_Slider_Thumb}" 
                                           Background="{TemplateBinding Background}" />
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource FlowViewer_Slider_RepeatButton}"
                                                  Command="Slider.IncreaseLarge"/>
                                </Track.IncreaseRepeatButton>
                            </Track>
                            <TickBar x:Name="BottomTick" Fill="{TemplateBinding Foreground}"
                                     Grid.Row="2" Placement="Bottom" Height="4" Visibility="Collapsed"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TickPlacement" Value="TopLeft">
                            <Setter TargetName="TopTick" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="TickPlacement" Value="BottomRight">
                            <Setter TargetName="BottomTick" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="TickPlacement" Value="Both">
                            <Setter TargetName="TopTick" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="BottomTick" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="IsSelectionRangeEnabled" Value="true">
                            <Setter TargetName="PART_SelectionRange" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="RenderTransform">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1.05" ScaleY="1.05"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Opacity" Value="1"/>
                            <Setter Property="RenderTransform">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1.05" ScaleY="1.05"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".3"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- FlowDocumentPageViewer -->
    <Style TargetType="{x:Type FlowDocumentPageViewer}" x:Key="PhotoFlowViewer">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="ContextMenu" Value="{DynamicResource FlowViewer_ContextMenu}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
        <Setter Property="Foreground" Value="{DynamicResource PageNavigationTextForeground}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type FlowDocumentPageViewer}">
                    <DockPanel LastChildFill="True" xml:lang="en-US">
                        <!-- Toolbar -->
                        <Grid DockPanel.Dock="Bottom" 
                              HorizontalAlignment="Stretch"
                              Background="Transparent"> 
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <!-- FindToolBar -->
                            <Border Grid.Column="0"
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Left"
                                    x:Name="PART_FindToolBarHost" 
                                    Visibility="Collapsed"/>
                            <!-- Page count and Nav buttons -->
                            <Grid Grid.Column="2" 
                                  HorizontalAlignment="Right" 
                                  VerticalAlignment="Bottom"
                                  Margin="0,0,0,5">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <!-- Previous Page -->
                                <RepeatButton Grid.Column="0" 
                                              Style="{DynamicResource SimpleButtonBaseStyle}"
                                              Margin="5,1"
                                              ToolTip="Previous Page"
                                              Command="NavigationCommands.PreviousPage"
                                              IsEnabled="{TemplateBinding CanGoToPreviousPage}"
                                              Focusable="False" >
                                    <Rectangle Height="25" Width="25" Fill="{DynamicResource LeftArrowToolbarDrawingBrush}"/>
                                </RepeatButton>
                                <!-- Page Count -->
                                <TextBlock Grid.Column="1" Style="{DynamicResource ToolbarTextBlockStyle}" TextAlignment="Center" MinWidth="80">
                                  <TextBlock.Text>
                                    <MultiBinding StringFormat="{}Page {0} of {1}">
                                      <Binding Path="MasterPageNumber" RelativeSource="{RelativeSource TemplatedParent}" />
                                      <Binding Path="PageCount" RelativeSource="{RelativeSource TemplatedParent}"  />
                                    </MultiBinding>
                                  </TextBlock.Text>
                                </TextBlock>
                                <!-- Next Page -->
                                <RepeatButton Grid.Column="2" 
                                              Style="{DynamicResource SimpleButtonBaseStyle}"
                                              ToolTip="Next Page" 
                                              Command="NavigationCommands.NextPage" 
                                              IsEnabled="{TemplateBinding CanGoToNextPage}"
                                              Focusable="False"
                                              Margin="5,1">
                                    <Rectangle Height="25" Width="25" Fill="{DynamicResource RightArrowToolbarDrawingBrush}"/>
                                </RepeatButton>
                            </Grid>
                        </Grid>
                        <!-- Page Content -->
                        <Border Margin="{TemplateBinding Padding}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <Grid>
                                <AdornerDecorator ClipToBounds="True">
                                    <DocumentPageView PageNumber="0" 
                                                      DocumentViewerBase.IsMasterPage="True"
                                                      KeyboardNavigation.TabIndex="1" 
                                                      KeyboardNavigation.TabNavigation="Local"
                                                      KeyboardNavigation.IsTabStop="False"/>
                                </AdornerDecorator>
                                <StackPanel Height="24" Width="50" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,35,0" Opacity=".9" >
                                    <Button Command="NavigationCommands.DecreaseZoom"
                                          AutomationProperties.AutomationId="ZoomOut" 
                                          ToolTip="Zoom out"
                                          Style="{DynamicResource ZoomInOutButtons}" 
                                          Height="22" Width="22">
                                        <Rectangle Margin="2" Height="18" Width="18"  Fill="{DynamicResource ZoomOutDrawingBrush}"/>
                                    </Button>
                                    <Button Command="NavigationCommands.IncreaseZoom" 
                                          AutomationProperties.AutomationId="ZoomIn" 
                                          ToolTip="Zoom in"
                                          Style="{DynamicResource ZoomInOutButtons}"
                                          Height="22" Width="22" Margin="5,0,0,0" >
                                        <Rectangle Margin="2" Height="18" Width="18"  Fill="{DynamicResource ZoomInDrawingBrush}"/>
                                    </Button>
                                </StackPanel>
                            </Grid>
                        </Border>
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>